package com.example.administrator.kotlintutorial.`class`.sealed

/**
 * Created by chensuilun on 2019/2/22.
 */
sealed class Skin {
    object Blue : Skin()
    object Red : Skin()
    //直接子类必须嵌套在密封类声明的内部
    data class CustomSkin(val color: String) : Skin()
}

fun getSkinColor(skin: Skin) = when (skin) {
    is Skin.Blue -> println("Blue")
    is Skin.Red -> println("Red")
    is Skin.CustomSkin -> println(skin.color)
}


fun main() {
    getSkinColor(Skin.Blue)
    getSkinColor(Skin.Red)
    getSkinColor(Skin.CustomSkin("Black"))
}
